/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package wiView.graphics.UI;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import wiBase.WiException;
import wiView.graphics.ScenarioMaker.Simulation;
/**
 *
 * @author Hoang
 */
public class FilterFrame extends javax.swing.JFrame {
    public FilterFrame(Simulation s){
        this();
        sim = s;
    }
    public FilterFrame(Simulation s, GraphForm mainFrame){
        this();
        sim = s;
        parent = mainFrame;
    }
    Simulation sim;
    GraphForm parent;
    ArrayList<String> clipboardNodeIds = new ArrayList<>();
//    public enum TimeType{nanoseconds,miliseconds,seconds,minutes,hours};

    public void addClipboardNodeIds(ArrayList<String> nodeIds){
        clipboardNodeIds.addAll(nodeIds);
    }
    public void addNode(String id){
        if(!nodes.contains(id)){
            nodes.add(id);
            DefaultListModel model = (DefaultListModel)jNodesList.getModel();
            model.addElement(id);
        }
    }
    
    public void clearNodes()
    {
        nodes.clear();
        DefaultListModel model = (DefaultListModel)jNodesList.getModel();
        model.clear();
    }
    
    public void clearPackets()
    {
        packets.clear();
        DefaultListModel model = (DefaultListModel)jPacketsList.getModel();
        model.clear();
    }
    public void addPacket(String id){
        if(!packets.contains(id)){
            packets.add(id);
            DefaultListModel model = (DefaultListModel)jPacketsList.getModel();
            model.addElement(id);
        }
    }
    public void removeNodeAt(int index)
    {
        nodes.remove(index);
        DefaultListModel model = (DefaultListModel)jNodesList.getModel();
        model.removeElementAt(index);
    }
    
    public void removePacketAt(int index)
    {
        packets.remove(index);
        DefaultListModel model = (DefaultListModel)jPacketsList.getModel();
        model.removeElementAt(index);
    }
    
    private int getSTime()
    {
        String sTime = jStartTimeTextField.getText().toString();
        String type = jComboBox1.getSelectedItem().toString();
        int iTime = 0;
        if(sTime.length()>10)
        {
            JOptionPane.showMessageDialog(this, "Input value too long");
        }
        try
        {
            iTime = Integer.parseInt(sTime);
        }catch(Exception e)
        {
            JOptionPane.showMessageDialog(this, "Input Error");
            return iTime;
        }
        switch(type){
            case "nanoseconds":
            {
                return iTime/1000000;
            }
            case "miliseconds":
            {
                return iTime;
            }
            case "seconds":
            {
                return iTime*1000;
            }
            case "minutes":
            {
                return iTime*60*1000;
            }
            case "hours":
            {
                return iTime*60*60*1000;
            }
        }
        return 0;
    }
    
    private int getETime()
    {
        String eTime = jEndTimeTextField.getText().toString();
        String type = jComboBox2.getSelectedItem().toString();
        int iTime = 0;
        
        if(eTime.length()>10)
        {
            JOptionPane.showMessageDialog(this, "Input value too long");
        }
        try
        {
            iTime = Integer.parseInt(eTime);
        }catch(Exception e)
        {
            JOptionPane.showMessageDialog(this, "Input Error");
            return iTime;
        }
        switch(type){
            case "nanoseconds":
            {
                return iTime/1000000;
            }
            case "miliseconds":
            {
                return iTime;
            }
            case "seconds":
            {
                return iTime*1000;
            }
            case "minutes":
            {
                return iTime*60*1000;
            }
            case "hours":
            {
                return iTime*60*60*1000;
            }
        }
        return 0;
    }
          
    ArrayList<String> nodes = new ArrayList<>();
    ArrayList<String> packets = new ArrayList<>();
    void initGroupBox(){
        packetButtonGroup.add(jAllPacketsRadioButton);
        packetButtonGroup.add(jPackinListRadioButton);
        //
        nodeButtonGroup.add(jAllNodesRadioButton);
        nodeButtonGroup.add(jNodesInListRadioButton);
        //
        eventButtonGroup.add(jAllEventsRadioButton);
        eventButtonGroup.add(jEventinTimeRadioButton);
        //
        
    }
    void clearClipboard(){
        jPacketsList.removeAll();
        jNodesList.removeAll();
    }
//    void BindList(){
//        clearClipboard();
//        jPacketsList.setListData(packets.toArray());
//        jNodesList.setListData(nodes.toArray());
//    }
    /**
     * Creates new form FilterFrame
     */
    public FilterFrame() {
        initComponents();
        initGroupBox();
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        packetButtonGroup = new javax.swing.ButtonGroup();
        nodeButtonGroup = new javax.swing.ButtonGroup();
        eventButtonGroup = new javax.swing.ButtonGroup();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jPacketsList = new javax.swing.JList();
        jAllPacketsRadioButton = new javax.swing.JRadioButton();
        jPackinListRadioButton = new javax.swing.JRadioButton();
        jLabel3 = new javax.swing.JLabel();
        jButtonClearPackets = new javax.swing.JButton();
        jTextFieldAddingPacket = new javax.swing.JTextField();
        jButtonAddPacket = new javax.swing.JButton();
        jButtonPacketDel = new javax.swing.JButton();
        jButtonPasteIDs = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jNodesList = new javax.swing.JList();
        jAllNodesRadioButton = new javax.swing.JRadioButton();
        jNodesInListRadioButton = new javax.swing.JRadioButton();
        jLabel4 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        jTextFieldAddingNode = new javax.swing.JTextField();
        jButtonAddNode = new javax.swing.JButton();
        jButtonNodeDel = new javax.swing.JButton();
        jButtonPasteNodeIds = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jStartTimeTextField = new javax.swing.JTextField();
        jEndTimeTextField = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jAllEventsRadioButton = new javax.swing.JRadioButton();
        jEventinTimeRadioButton = new javax.swing.JRadioButton();
        jComboBox1 = new javax.swing.JComboBox();
        jComboBox2 = new javax.swing.JComboBox();
        jStartSimuButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Option");
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jTabbedPane1.setTabLayoutPolicy(javax.swing.JTabbedPane.SCROLL_TAB_LAYOUT);

        jPacketsList.setModel(new DefaultListModel<String>());
        jScrollPane3.setViewportView(jPacketsList);

        jAllPacketsRadioButton.setSelected(true);
        jAllPacketsRadioButton.setText("All packets");

        jPackinListRadioButton.setText("Packets in list box");

        jLabel3.setText("Packet Filter");

        jButtonClearPackets.setText("Clear");
        jButtonClearPackets.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonClearPacketsActionPerformed(evt);
            }
        });

        jButtonAddPacket.setText("Add");
        jButtonAddPacket.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAddPacketActionPerformed(evt);
            }
        });

        jButtonPacketDel.setText("Delete");
        jButtonPacketDel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonPacketDelActionPerformed(evt);
            }
        });

        jButtonPasteIDs.setText("PasteID(s)");
        jButtonPasteIDs.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonPasteIDsActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(34, 34, 34)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jAllPacketsRadioButton)
                    .addComponent(jPackinListRadioButton))
                .addGap(49, 49, 49)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jTextFieldAddingPacket)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jButtonAddPacket)
                            .addComponent(jButtonPasteIDs, javax.swing.GroupLayout.DEFAULT_SIZE, 86, Short.MAX_VALUE)
                            .addComponent(jButtonClearPackets, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButtonPacketDel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap(64, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(7, 7, 7)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 251, Short.MAX_VALUE)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jButtonPasteIDs)
                                .addGap(10, 10, 10)
                                .addComponent(jButtonClearPackets)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jButtonPacketDel)
                                .addGap(0, 0, Short.MAX_VALUE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButtonAddPacket)
                            .addComponent(jTextFieldAddingPacket, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jAllPacketsRadioButton)
                        .addGap(18, 18, 18)
                        .addComponent(jPackinListRadioButton)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );

        jTabbedPane1.addTab("Packets", jPanel2);

        jNodesList.setModel(new DefaultListModel<String>());
        jScrollPane1.setViewportView(jNodesList);

        jAllNodesRadioButton.setSelected(true);
        jAllNodesRadioButton.setText("All nodes");

        jNodesInListRadioButton.setText("Nodes in list box");

        jLabel4.setText("Node Filter");

        jButton2.setText("Clear");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButtonAddNode.setText("Add");
        jButtonAddNode.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAddNodeActionPerformed(evt);
            }
        });

        jButtonNodeDel.setText("Delete");
        jButtonNodeDel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonNodeDelActionPerformed(evt);
            }
        });

        jButtonPasteNodeIds.setText("Paste ID(s)");
        jButtonPasteNodeIds.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonPasteNodeIdsActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(40, 40, 40)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jAllNodesRadioButton)
                    .addComponent(jNodesInListRadioButton))
                .addGap(52, 52, 52)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jTextFieldAddingNode)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 188, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jButtonNodeDel, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jButtonPasteNodeIds)
                            .addComponent(jButtonAddNode))))
                .addContainerGap(65, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGap(5, 5, 5)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jAllNodesRadioButton)
                        .addGap(18, 18, 18)
                        .addComponent(jNodesInListRadioButton))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jButton2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButtonNodeDel)
                        .addGap(18, 18, 18)
                        .addComponent(jButtonPasteNodeIds)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldAddingNode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonAddNode))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Nodes", jPanel1);

        jStartTimeTextField.setText("0");

        jEndTimeTextField.setText("100");

        jLabel1.setText("Start time");

        jLabel2.setText("Last time");

        jAllEventsRadioButton.setSelected(true);
        jAllEventsRadioButton.setText("All events");

        jEventinTimeRadioButton.setText("Events in time span");
        jEventinTimeRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jEventinTimeRadioButtonActionPerformed(evt);
            }
        });

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "nanoseconds", "miliseconds", "seconds", "minutes", "hours" }));

        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "nanoseconds", "miliseconds", "seconds", "minutes", "hours" }));

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(79, 79, 79)
                                .addComponent(jLabel1))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jLabel2)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jStartTimeTextField)
                            .addComponent(jEndTimeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(33, 33, 33)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jEventinTimeRadioButton)
                            .addComponent(jAllEventsRadioButton))))
                .addContainerGap(211, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addComponent(jAllEventsRadioButton)
                .addGap(18, 18, 18)
                .addComponent(jEventinTimeRadioButton)
                .addGap(7, 7, 7)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jStartTimeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jEndTimeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2)
                    .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(168, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Events", jPanel3);

        jStartSimuButton.setText("Save");
        jStartSimuButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jStartSimuButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1)
            .addGroup(layout.createSequentialGroup()
                .addGap(228, 228, 228)
                .addComponent(jStartSimuButton, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jTabbedPane1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jStartSimuButton)
                .addGap(21, 21, 21))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        // TODO add your handling code here:
//        BindList();
    }//GEN-LAST:event_formWindowOpened

    private void jStartSimuButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jStartSimuButtonActionPerformed
        // TODO add your handling code here:   
        //PacketTab
        this.setVisible(false);
        if(jAllPacketsRadioButton.isSelected())
        {
            //code packets
        }
        if(jPackinListRadioButton.isSelected())
        {
            // code
            //List<String> packetsSelected = jPacketsList.getSelectedValuesList();
            {
                try {
                    sim.setPacketsToSim(packets);
                    
                } catch (WiException ex) {
                    /// Show dialog here
                    System.out.println("FilterFrame: can not set packets to simulate");
                }
            }
        }
        //nodes Tab
        if(jAllNodesRadioButton.isSelected())
        {
            //code nodes
        }
        if(jNodesInListRadioButton.isSelected())
        {
            //code 
            if(sim != null)
            {
                try {
                    sim.setNodesToSim(nodes);
                } catch (WiException ex) {
                    System.out.println("can not set node to simulate");
                    ///Show Dialog here
                }
            }
        }
        if(jAllEventsRadioButton.isSelected())
        {
            //code
        }
        if(jEventinTimeRadioButton.isSelected())
        {
            if(sim != null){
             sim.setStartTime(getSTime()/1000);   
             sim.setEndTime(getETime()/1000);
            }
        }
        // clear raw data
        clipboardNodeIds.clear();
    }//GEN-LAST:event_jStartSimuButtonActionPerformed

    private void jEventinTimeRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jEventinTimeRadioButtonActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jEventinTimeRadioButtonActionPerformed

    private void jButtonClearPacketsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonClearPacketsActionPerformed
        // TODO add your handling code here:
        clearPackets();
    }//GEN-LAST:event_jButtonClearPacketsActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        clearNodes();
    }//GEN-LAST:event_jButton2ActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        // TODO add your handling code here:
        this.setVisible(false);
    }//GEN-LAST:event_formWindowClosing

    private void jButtonAddPacketActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAddPacketActionPerformed
        // TODO add your handling code here:
        try{
             Integer.parseInt(jTextFieldAddingPacket.getText());
             addPacket(jTextFieldAddingPacket.getText());
             jTextFieldAddingPacket.setText("");
        }catch(Exception e){
            JOptionPane.showMessageDialog(this, "Input error");
        }
    }//GEN-LAST:event_jButtonAddPacketActionPerformed

    private void jButtonAddNodeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAddNodeActionPerformed
        // TODO add your handling code here:
        try{
             Integer.parseInt(jTextFieldAddingNode.getText());
             addPacket(jTextFieldAddingNode.getText());
             jTextFieldAddingNode.setText("");
        }catch(Exception e){
            JOptionPane.showMessageDialog(this, "Input error");
        }
    }//GEN-LAST:event_jButtonAddNodeActionPerformed

    private void jButtonPasteNodeIdsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPasteNodeIdsActionPerformed
        // TODO add your handling code here:
        for (String id : clipboardNodeIds) {
            addNode(id);
        }
    }//GEN-LAST:event_jButtonPasteNodeIdsActionPerformed

    private void jButtonPacketDelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPacketDelActionPerformed
        // TODO add your handling code here:
        int i = jPacketsList.getSelectedIndex();
        if(i > -1)
            removePacketAt(i);
    }//GEN-LAST:event_jButtonPacketDelActionPerformed

    private void jButtonNodeDelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNodeDelActionPerformed
        // TODO add your handling code here:
        int i = jNodesList.getSelectedIndex();
        if(i > -1)
            removeNodeAt(i);
    }//GEN-LAST:event_jButtonNodeDelActionPerformed

    private void jButtonPasteIDsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPasteIDsActionPerformed
        // TODO add your handling code here:
        for (String id : parent.getCopiedPacketIDs()) {
            addPacket(id);
        }
        parent.getCopiedPacketIDs().clear();
    }//GEN-LAST:event_jButtonPasteIDsActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FilterFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FilterFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FilterFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FilterFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FilterFrame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup eventButtonGroup;
    private javax.swing.JRadioButton jAllEventsRadioButton;
    private javax.swing.JRadioButton jAllNodesRadioButton;
    private javax.swing.JRadioButton jAllPacketsRadioButton;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButtonAddNode;
    private javax.swing.JButton jButtonAddPacket;
    private javax.swing.JButton jButtonClearPackets;
    private javax.swing.JButton jButtonNodeDel;
    private javax.swing.JButton jButtonPacketDel;
    private javax.swing.JButton jButtonPasteIDs;
    private javax.swing.JButton jButtonPasteNodeIds;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JTextField jEndTimeTextField;
    private javax.swing.JRadioButton jEventinTimeRadioButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JRadioButton jNodesInListRadioButton;
    private javax.swing.JList jNodesList;
    private javax.swing.JList jPacketsList;
    private javax.swing.JRadioButton jPackinListRadioButton;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JButton jStartSimuButton;
    private javax.swing.JTextField jStartTimeTextField;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextField jTextFieldAddingNode;
    private javax.swing.JTextField jTextFieldAddingPacket;
    private javax.swing.ButtonGroup nodeButtonGroup;
    private javax.swing.ButtonGroup packetButtonGroup;
    // End of variables declaration//GEN-END:variables
}
